import {ColumnsType} from "antd/es/table";
import {SecurityRole} from "type/entity/SecurityRole";
import {columnDataIndex, columnOrder, columnRemark} from "./index";
import IconFont from "util/icon-util";
import {Space} from "antd";
import {Link} from "react-router-dom";


const roleColumns: ColumnsType<SecurityRole> = [
    columnDataIndex,
    {
        key: 'id',
        dataIndex: 'id',
        title: '角色编号',
        width: 110,
        align: "center",
    },
    {
        key: 'authority',
        dataIndex: 'authority',
        title: '角色定义',
        width: 150,
        align: "center",
        fixed: "left"
    },
    {
        key: 'explain',
        dataIndex: 'explain',
        title: '角色说明',
        width: 150,
        // align: "center" ,
        ellipsis: {showTitle: false},
    },
    {
        key: 'icon',
        dataIndex: 'icon',
        title: '图标',
        width: 60,
        align: "center",
        render: (value, record) => {
            return <IconFont style={{fontSize: "20px"}} type={record.icon} />;
        }
    },
    columnOrder,
    columnRemark,
    {
        key: "options",
        title: "操作",
        dataIndex: "options",
        align: "center",
        width: 160,
        fixed: "right",
        render: (_, record, __) => {
            return <Space size={15}>
                <Link key={"role-details"} to={"details"} state={record}>详情</Link>
                <Link key={"role-update"} to={"update"} state={record}>更新</Link>
                <Link key={"role-authority"} to={"path"} state={record}>授权</Link>
                <Link key={"role-delete"} style={{color: "#c13c3c"}} to={"delete"} state={record}>删除</Link>
            </Space>;
        }
    }
];

export default roleColumns;